
<!DOCTYPE HTML>
<html lang="zh-hans" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>Promise · JavaScript学习</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        <meta name="author" content="Veng">
        
        
    
    <link rel="stylesheet" href="../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-pageview-count/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-chapter-fold/chapter-fold.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-back-to-top-button/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-code/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="../基础/generator.html" />
    
    
    <link rel="prev" href="../基础/箭头函数.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="输入并搜索" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    Introduction
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../基础/基础.html">
            
                <a href="../基础/基础.html">
            
                    
                    基础
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.1" data-path="../基础/变量.html">
            
                <a href="../基础/变量.html">
            
                    
                    数据类型
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.2" data-path="../基础/let和const命令.html">
            
                <a href="../基础/let和const命令.html">
            
                    
                    let和const命令
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.3" data-path="../基础/数值.html">
            
                <a href="../基础/数值.html">
            
                    
                    数值
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.4" data-path="../基础/字符串.html">
            
                <a href="../基础/字符串.html">
            
                    
                    字符串
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.5" data-path="../基础/对象.html">
            
                <a href="../基础/对象.html">
            
                    
                    对象
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.6" data-path="../基础/数组.html">
            
                <a href="../基础/数组.html">
            
                    
                    数组
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.7" data-path="../基础/Symbol.html">
            
                <a href="../基础/Symbol.html">
            
                    
                    Symbol
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.8" data-path="../基础/函数.html">
            
                <a href="../基础/函数.html">
            
                    
                    函数
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.8.1" data-path="../基础/函数的扩展.html">
            
                <a href="../基础/函数的扩展.html">
            
                    
                    函数的扩展
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.8.2" data-path="../基础/变量的解构赋值.html">
            
                <a href="../基础/变量的解构赋值.html">
            
                    
                    变量作用域与解构赋值
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.8.3" data-path="../基础/函数3.html">
            
                <a href="../基础/函数3.html">
            
                    
                    方法函数
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.8.4" data-path="../基础/高阶函数.html">
            
                <a href="../基础/高阶函数.html">
            
                    
                    高阶函数
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.8.4.1" data-path="../基础/map-reduce.html">
            
                <a href="../基础/map-reduce.html">
            
                    
                    map/reduce
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.8.4.2" data-path="../基础/filter.html">
            
                <a href="../基础/filter.html">
            
                    
                    filter
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.8.4.3" data-path="../基础/sort.html">
            
                <a href="../基础/sort.html">
            
                    
                    sort
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.8.4.4" data-path="../基础/array其他方法.html">
            
                <a href="../基础/array其他方法.html">
            
                    
                    array其他方法
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.2.8.5" data-path="../基础/闭包.html">
            
                <a href="../基础/闭包.html">
            
                    
                    闭包
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.8.6" data-path="../基础/箭头函数.html">
            
                <a href="../基础/箭头函数.html">
            
                    
                    箭头函数
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.2.8.7" data-path="Promise.html">
            
                <a href="Promise.html">
            
                    
                    Promise
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.8.8" data-path="../基础/generator.html">
            
                <a href="../基础/generator.html">
            
                    
                    generator
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.8.9" data-path="../基础/async.html">
            
                <a href="../基础/async.html">
            
                    
                    async
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.2.9" data-path="../基础/标准对象.html">
            
                <a href="../基础/标准对象.html">
            
                    
                    标准对象
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.9.1" data-path="../基础/SetMap.html">
            
                <a href="../基础/SetMap.html">
            
                    
                    Set,Map
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.9.2" data-path="../基础/Date.html">
            
                <a href="../基础/Date.html">
            
                    
                    Date
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.9.3" data-path="../基础/Math.html">
            
                <a href="../基础/Math.html">
            
                    
                    Math
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.9.4" data-path="../基础/Proxy.html">
            
                <a href="../基础/Proxy.html">
            
                    
                    Proxy
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.9.5" data-path="../基础/RepExp.html">
            
                <a href="../基础/RepExp.html">
            
                    
                    正则表达式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.9.6" data-path="../基础/正则表达式.html">
            
                <a href="../基础/正则表达式.html">
            
                    
                    正则表达式别篇
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.9.7" data-path="../基础/json.html">
            
                <a href="../基础/json.html">
            
                    
                    JSON
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.2.10" data-path="../基础/面向对象编程.html">
            
                <a href="../基础/面向对象编程.html">
            
                    
                    面向对象编程
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.10.1" data-path="../基础/对象的扩展.html">
            
                <a href="../基础/对象的扩展.html">
            
                    
                    对象的扩展
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.10.2" data-path="../基础/创建对象.html">
            
                <a href="../基础/创建对象.html">
            
                    
                    创建对象
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.10.3" data-path="../基础/原型继承.html">
            
                <a href="../基础/原型继承.html">
            
                    
                    原型继承
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.10.4" data-path="../基础/class继承.html">
            
                <a href="../基础/class继承.html">
            
                    
                    class继承
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.10.5" data-path="../基础/模块化Module.html">
            
                <a href="../基础/模块化Module.html">
            
                    
                    模块化Module
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.2.11" data-path="../基础/异常处理.html">
            
                <a href="../基础/异常处理.html">
            
                    
                    异常处理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.12" data-path="../基础/编程风格.html">
            
                <a href="../基础/编程风格.html">
            
                    
                    编程风格
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="../js扩展/js扩展.html">
            
                <a href="../js扩展/js扩展.html">
            
                    
                    js 扩展
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1" data-path="../js扩展/字符串.html">
            
                <a href="../js扩展/字符串.html">
            
                    
                    字符串
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="浏览器.html">
            
                <a href="浏览器.html">
            
                    
                    浏览器
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.1" data-path="浏览器对象.html">
            
                <a href="浏览器对象.html">
            
                    
                    浏览器对象
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2" data-path="操作DOM.html">
            
                <a href="操作DOM.html">
            
                    
                    操作DOM
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.2.1" data-path="更新DOM.html">
            
                <a href="更新DOM.html">
            
                    
                    更新DOM
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2.2" data-path="插入DOM.html">
            
                <a href="插入DOM.html">
            
                    
                    插入DOM
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2.3" data-path="删除DOM.html">
            
                <a href="删除DOM.html">
            
                    
                    删除DOM
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4.3" data-path="DOM事件.html">
            
                <a href="DOM事件.html">
            
                    
                    DOM事件
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.4" data-path="操作表单.html">
            
                <a href="操作表单.html">
            
                    
                    操作表单
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.5" data-path="操作文件.html">
            
                <a href="操作文件.html">
            
                    
                    操作文件
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.6" data-path="AJAX.html">
            
                <a href="AJAX.html">
            
                    
                    AJAX
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.7" data-path="Canvas.html">
            
                <a href="Canvas.html">
            
                    
                    Canvas
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="../Jquery/jquery.html">
            
                <a href="../Jquery/jquery.html">
            
                    
                    Jquery
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.5.1" data-path="../Jquery/选择器.html">
            
                <a href="../Jquery/选择器.html">
            
                    
                    选择器
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.5.1.1" data-path="../Jquery/层级选择器.html">
            
                <a href="../Jquery/层级选择器.html">
            
                    
                    层级选择器
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.1.2" data-path="../Jquery/查找和过滤.html">
            
                <a href="../Jquery/查找和过滤.html">
            
                    
                    查找和过滤
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.5.2" data-path="../Jquery/操作DOM.html">
            
                <a href="../Jquery/操作DOM.html">
            
                    
                    操作DOM
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.5.2.1" data-path="../Jquery/修改DOM结构.html">
            
                <a href="../Jquery/修改DOM结构.html">
            
                    
                    修改DOM结构
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.5.3" data-path="../Jquery/事件.html">
            
                <a href="../Jquery/事件.html">
            
                    
                    事件
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.4" data-path="../Jquery/动画.html">
            
                <a href="../Jquery/动画.html">
            
                    
                    动画
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.5" data-path="../Jquery/AJAX.html">
            
                <a href="../Jquery/AJAX.html">
            
                    
                    AJAX
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.6" data-path="../Jquery/扩展.html">
            
                <a href="../Jquery/扩展.html">
            
                    
                    扩展
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="../nodejs/nodejs.html">
            
                <a href="../nodejs/nodejs.html">
            
                    
                    Nodejs
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.6.1" data-path="../nodejs/模块.html">
            
                <a href="../nodejs/模块.html">
            
                    
                    模块
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.2" data-path="../nodejs/path.html">
            
                <a href="../nodejs/path.html">
            
                    
                    path
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.3" data-path="../nodejs/文件操作.html">
            
                <a href="../nodejs/文件操作.html">
            
                    
                    文件操作 fs
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.4" data-path="../nodejs/流Stream.html">
            
                <a href="../nodejs/流Stream.html">
            
                    
                    流Stream
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.5" data-path="../nodejs/zlib压缩解压缩.html">
            
                <a href="../nodejs/zlib压缩解压缩.html">
            
                    
                    zlib压缩解压缩
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.6" data-path="../nodejs/net网络.html">
            
                <a href="../nodejs/net网络.html">
            
                    
                    net网络
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.7" data-path="../nodejs/http.html">
            
                <a href="../nodejs/http.html">
            
                    
                    http
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.8" data-path="../nodejs/express框架.html">
            
                <a href="../nodejs/express框架.html">
            
                    
                    express框架
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.9" data-path="../nodejs/process进程.html">
            
                <a href="../nodejs/process进程.html">
            
                    
                    process 进程
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.10" data-path="../nodejs/child_process.html">
            
                <a href="../nodejs/child_process.html">
            
                    
                    child_process
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.11" data-path="../nodejs/os.html">
            
                <a href="../nodejs/os.html">
            
                    
                    os-操作系统
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="../react/react.html">
            
                <a href="../react/react.html">
            
                    
                    React
            
                </a>
            

            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            本书使用 GitBook 发布
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >Promise</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h1 id="promise">Promise</h1>
<p>&#x5728;JavaScript&#x7684;&#x4E16;&#x754C;&#x4E2D;&#xFF0C;&#x6240;&#x6709;&#x4EE3;&#x7801;&#x90FD;&#x662F;&#x5355;&#x7EBF;&#x7A0B;&#x6267;&#x884C;&#x7684;&#x3002;</p>
<p>&#x7531;&#x4E8E;&#x8FD9;&#x4E2A;&#x201C;&#x7F3A;&#x9677;&#x201D;&#xFF0C;&#x5BFC;&#x81F4;JavaScript&#x7684;&#x6240;&#x6709;&#x7F51;&#x7EDC;&#x64CD;&#x4F5C;&#xFF0C;&#x6D4F;&#x89C8;&#x5668;&#x4E8B;&#x4EF6;&#xFF0C;&#x90FD;&#x5FC5;&#x987B;&#x662F;&#x5F02;&#x6B65;&#x6267;&#x884C;&#x3002;&#x5F02;&#x6B65;&#x6267;&#x884C;&#x53EF;&#x4EE5;&#x7528;&#x56DE;&#x8C03;&#x51FD;&#x6570;&#x5B9E;&#x73B0;&#xFF1A;</p>
<pre><code class="lang-javascript"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">callback</span>(<span class="hljs-params"></span>) </span>{
    <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&apos;Done&apos;</span>);
}
<span class="hljs-built_in">console</span>.log(<span class="hljs-string">&apos;before setTimeout()&apos;</span>);
setTimeout(callback, <span class="hljs-number">1000</span>); <span class="hljs-comment">// 1&#x79D2;&#x949F;&#x540E;&#x8C03;&#x7528;callback&#x51FD;&#x6570;</span>
<span class="hljs-built_in">console</span>.log(<span class="hljs-string">&apos;after setTimeout()&apos;</span>);
</code></pre>
<p>&#x89C2;&#x5BDF;&#x4E0A;&#x8FF0;&#x4EE3;&#x7801;&#x6267;&#x884C;&#xFF0C;&#x5728;Chrome&#x7684;&#x63A7;&#x5236;&#x53F0;&#x8F93;&#x51FA;&#x53EF;&#x4EE5;&#x770B;&#x5230;&#xFF1A;</p>
<pre><code class="lang-shell">before setTimeout()
after setTimeout()
(&#x7B49;&#x5F85;1&#x79D2;&#x540E;)
Done
</code></pre>
<p>&#x53EF;&#x89C1;&#xFF0C;&#x5F02;&#x6B65;&#x64CD;&#x4F5C;&#x4F1A;&#x5728;&#x5C06;&#x6765;&#x7684;&#x67D0;&#x4E2A;&#x65F6;&#x95F4;&#x70B9;&#x89E6;&#x53D1;&#x4E00;&#x4E2A;&#x51FD;&#x6570;&#x8C03;&#x7528;&#x3002;AJAX&#x5C31;&#x662F;&#x5178;&#x578B;&#x7684;&#x5F02;&#x6B65;&#x64CD;&#x4F5C;.</p>
<p>&#x6211;&#x4EEC;&#x5148;&#x770B;&#x4E00;&#x4E2A;&#x6700;&#x7B80;&#x5355;&#x7684;Promise&#x4F8B;&#x5B50;&#xFF1A;&#x751F;&#x6210;&#x4E00;&#x4E2A;0-2&#x4E4B;&#x95F4;&#x7684;&#x968F;&#x673A;&#x6570;&#xFF0C;&#x5982;&#x679C;&#x5C0F;&#x4E8E;1&#xFF0C;&#x5219;&#x7B49;&#x5F85;&#x4E00;&#x6BB5;&#x65F6;&#x95F4;&#x540E;&#x8FD4;&#x56DE;&#x6210;&#x529F;&#xFF0C;&#x5426;&#x5219;&#x8FD4;&#x56DE;&#x5931;&#x8D25;&#xFF1A;</p>
<pre><code class="lang-javascript"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">test</span>(<span class="hljs-params">resolve, reject</span>) </span>{
    <span class="hljs-keyword">var</span> timeOut = <span class="hljs-built_in">Math</span>.random() * <span class="hljs-number">2</span>;
    log(<span class="hljs-string">&apos;set timeout to: &apos;</span> + timeOut + <span class="hljs-string">&apos; seconds.&apos;</span>);
    setTimeout(<span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params"></span>) </span>{
        <span class="hljs-keyword">if</span> (timeOut &lt; <span class="hljs-number">1</span>) {
            log(<span class="hljs-string">&apos;call resolve()...&apos;</span>);
            resolve(<span class="hljs-string">&apos;200 OK&apos;</span>);
        }
        <span class="hljs-keyword">else</span> {
            log(<span class="hljs-string">&apos;call reject()...&apos;</span>);
            reject(<span class="hljs-string">&apos;timeout in &apos;</span> + timeOut + <span class="hljs-string">&apos; seconds.&apos;</span>);
        }
    }, timeOut * <span class="hljs-number">1000</span>);
}
</code></pre>
<p>&#x8FD9;&#x4E2A;<code>test()</code>&#x51FD;&#x6570;&#x6709;&#x4E24;&#x4E2A;&#x53C2;&#x6570;&#xFF0C;&#x8FD9;&#x4E24;&#x4E2A;&#x53C2;&#x6570;&#x90FD;&#x662F;&#x51FD;&#x6570;&#xFF0C;&#x5982;&#x679C;&#x6267;&#x884C;&#x6210;&#x529F;&#xFF0C;&#x6211;&#x4EEC;&#x5C06;&#x8C03;&#x7528;<code>resolve(&apos;200 OK&apos;)</code>&#xFF0C;&#x5982;&#x679C;&#x6267;&#x884C;&#x5931;&#x8D25;&#xFF0C;&#x6211;&#x4EEC;&#x5C06;&#x8C03;&#x7528;<code>reject(&apos;timeout in &apos; + timeOut + &apos; seconds.&apos;)</code>&#x3002;&#x53EF;&#x4EE5;&#x770B;&#x51FA;&#xFF0C;<code>test()</code>&#x51FD;&#x6570;&#x53EA;&#x5173;&#x5FC3;&#x81EA;&#x8EAB;&#x7684;&#x903B;&#x8F91;&#xFF0C;&#x5E76;&#x4E0D;&#x5173;&#x5FC3;&#x5177;&#x4F53;&#x7684;<code>resolve</code>&#x548C;<code>reject</code>&#x5C06;&#x5982;&#x4F55;&#x5904;&#x7406;&#x7ED3;&#x679C;&#x3002;</p>
<p>&#x6709;&#x4E86;&#x6267;&#x884C;&#x51FD;&#x6570;&#xFF0C;&#x6211;&#x4EEC;&#x5C31;&#x53EF;&#x4EE5;&#x7528;&#x4E00;&#x4E2A;Promise&#x5BF9;&#x8C61;&#x6765;&#x6267;&#x884C;&#x5B83;&#xFF0C;&#x5E76;&#x5728;&#x5C06;&#x6765;&#x67D0;&#x4E2A;&#x65F6;&#x523B;&#x83B7;&#x5F97;&#x6210;&#x529F;&#x6216;&#x5931;&#x8D25;&#x7684;&#x7ED3;&#x679C;&#xFF1A;</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">var</span> p1 = <span class="hljs-keyword">new</span> <span class="hljs-built_in">Promise</span>(test);
<span class="hljs-keyword">var</span> p2 = p1.then(<span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params">result</span>) </span>{
    <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&apos;&#x6210;&#x529F;&#xFF1A;&apos;</span> + result);
});
<span class="hljs-keyword">var</span> p3 = p2.catch(<span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params">reason</span>) </span>{
    <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&apos;&#x5931;&#x8D25;&#xFF1A;&apos;</span> + reason);
});
</code></pre>
<p>&#x53D8;&#x91CF;<code>p1</code>&#x662F;&#x4E00;&#x4E2A;Promise&#x5BF9;&#x8C61;&#xFF0C;&#x5B83;&#x8D1F;&#x8D23;&#x6267;&#x884C;<code>test</code>&#x51FD;&#x6570;&#x3002;&#x7531;&#x4E8E;<code>test</code>&#x51FD;&#x6570;&#x5728;&#x5185;&#x90E8;&#x662F;&#x5F02;&#x6B65;&#x6267;&#x884C;&#x7684;&#xFF0C;&#x5F53;<code>test</code>&#x51FD;&#x6570;&#x6267;&#x884C;&#x6210;&#x529F;&#x65F6;&#xFF0C;&#x6211;&#x4EEC;&#x544A;&#x8BC9;Promise&#x5BF9;&#x8C61;&#xFF1A;</p>
<pre><code class="lang-javascript"><span class="hljs-comment">// &#x5982;&#x679C;&#x6210;&#x529F;&#xFF0C;&#x6267;&#x884C;&#x8FD9;&#x4E2A;&#x51FD;&#x6570;&#xFF1A;</span>
p1.then(<span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params">result</span>) </span>{
    <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&apos;&#x6210;&#x529F;&#xFF1A;&apos;</span> + result);
});
</code></pre>
<p>&#x5F53;<code>test</code>&#x51FD;&#x6570;&#x6267;&#x884C;&#x5931;&#x8D25;&#x65F6;&#xFF0C;&#x6211;&#x4EEC;&#x544A;&#x8BC9;Promise&#x5BF9;&#x8C61;&#xFF1A;</p>
<pre><code class="lang-javascript">p2.catch(<span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params">reason</span>) </span>{
    <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&apos;&#x5931;&#x8D25;&#xFF1A;&apos;</span> + reason);
});
</code></pre>
<p>Promise&#x5BF9;&#x8C61;&#x53EF;&#x4EE5;&#x4E32;&#x8054;&#x8D77;&#x6765;&#xFF0C;&#x6240;&#x4EE5;&#x4E0A;&#x8FF0;&#x4EE3;&#x7801;&#x53EF;&#x4EE5;&#x7B80;&#x5316;&#x4E3A;&#xFF1A;</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">new</span> <span class="hljs-built_in">Promise</span>(test).then(<span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params">result</span>) </span>{
    <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&apos;&#x6210;&#x529F;&#xFF1A;&apos;</span> + result);
}).catch(<span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params">reason</span>) </span>{
    <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&apos;&#x5931;&#x8D25;&#xFF1A;&apos;</span> + reason);
});
</code></pre>
<p>&#x53EF;&#x89C1;Promise&#x6700;&#x5927;&#x7684;&#x597D;&#x5904;&#x662F;&#x5728;&#x5F02;&#x6B65;&#x6267;&#x884C;&#x7684;&#x6D41;&#x7A0B;&#x4E2D;&#xFF0C;&#x628A;&#x6267;&#x884C;&#x4EE3;&#x7801;&#x548C;&#x5904;&#x7406;&#x7ED3;&#x679C;&#x7684;&#x4EE3;&#x7801;&#x6E05;&#x6670;&#x5730;&#x5206;&#x79BB;&#x4E86;&#xFF1A;</p>
<p><img src="assets/l.png" alt="promise"></p>
<p>Promise&#x8FD8;&#x53EF;&#x4EE5;&#x505A;&#x66F4;&#x591A;&#x7684;&#x4E8B;&#x60C5;&#xFF0C;&#x6BD4;&#x5982;&#xFF0C;&#x6709;&#x82E5;&#x5E72;&#x4E2A;&#x5F02;&#x6B65;&#x4EFB;&#x52A1;&#xFF0C;&#x9700;&#x8981;&#x5148;&#x505A;&#x4EFB;&#x52A1;1&#xFF0C;&#x5982;&#x679C;&#x6210;&#x529F;&#x540E;&#x518D;&#x505A;&#x4EFB;&#x52A1;2&#xFF0C;&#x4EFB;&#x4F55;&#x4EFB;&#x52A1;&#x5931;&#x8D25;&#x5219;&#x4E0D;&#x518D;&#x7EE7;&#x7EED;&#x5E76;&#x6267;&#x884C;&#x9519;&#x8BEF;&#x5904;&#x7406;&#x51FD;&#x6570;&#x3002;</p>
<p>&#x8981;&#x4E32;&#x884C;&#x6267;&#x884C;&#x8FD9;&#x6837;&#x7684;&#x5F02;&#x6B65;&#x4EFB;&#x52A1;&#xFF0C;&#x4E0D;&#x7528;Promise&#x9700;&#x8981;&#x5199;&#x4E00;&#x5C42;&#x4E00;&#x5C42;&#x7684;&#x5D4C;&#x5957;&#x4EE3;&#x7801;&#x3002;&#x6709;&#x4E86;Promise&#xFF0C;&#x6211;&#x4EEC;&#x53EA;&#x9700;&#x8981;&#x7B80;&#x5355;&#x5730;&#x5199;&#xFF1A;</p>
<pre><code class="lang-javascript">job1.then(job2).then(job3).catch(handleError);
</code></pre>
<p>&#x5176;&#x4E2D;&#xFF0C;<code>job1</code>&#x3001;<code>job2</code>&#x548C;<code>job3</code>&#x90FD;&#x662F;Promise&#x5BF9;&#x8C61;&#x3002;</p>
<p>&#x4F8B;&#x5982;&#xFF1A;</p>
<pre><code class="lang-javascript"><span class="hljs-comment">// 0.5&#x79D2;&#x540E;&#x8FD4;&#x56DE;input*input&#x7684;&#x8BA1;&#x7B97;&#x7ED3;&#x679C;:</span>
<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">multiply</span>(<span class="hljs-params">input</span>) </span>{
    <span class="hljs-keyword">return</span> <span class="hljs-keyword">new</span> <span class="hljs-built_in">Promise</span>(<span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params">resolve, reject</span>) </span>{
        log(<span class="hljs-string">&apos;calculating &apos;</span> + input + <span class="hljs-string">&apos; x &apos;</span> + input + <span class="hljs-string">&apos;...&apos;</span>);
        setTimeout(resolve, <span class="hljs-number">500</span>, input * input);
    });
}

<span class="hljs-comment">// 0.5&#x79D2;&#x540E;&#x8FD4;&#x56DE;input+input&#x7684;&#x8BA1;&#x7B97;&#x7ED3;&#x679C;:</span>
<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">add</span>(<span class="hljs-params">input</span>) </span>{
    <span class="hljs-keyword">return</span> <span class="hljs-keyword">new</span> <span class="hljs-built_in">Promise</span>(<span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params">resolve, reject</span>) </span>{
        log(<span class="hljs-string">&apos;calculating &apos;</span> + input + <span class="hljs-string">&apos; + &apos;</span> + input + <span class="hljs-string">&apos;...&apos;</span>);
        setTimeout(resolve, <span class="hljs-number">500</span>, input + input);
    });
}

<span class="hljs-keyword">var</span> p = <span class="hljs-keyword">new</span> <span class="hljs-built_in">Promise</span>(<span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params">resolve, reject</span>) </span>{
    log(<span class="hljs-string">&apos;start new Promise...&apos;</span>);
    resolve(<span class="hljs-number">123</span>);
});

p.then(multiply)
 .then(add)
 .then(multiply)
 .then(add)
 .then(<span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params">result</span>) </span>{
    log(<span class="hljs-string">&apos;Got value: &apos;</span> + result);
});
</code></pre>
<pre><code class="lang-shell">Log:

start new Promise...

calculating 123 x 123...

calculating 15129 + 15129...

calculating 30258 x 30258...

calculating 915546564 + 915546564...

Got value: 1831093128
</code></pre>
<p>&#x73B0;&#x5728;&#xFF0C;&#x6211;&#x4EEC;&#x628A;AJAX&#x5F02;&#x6B65;&#x6267;&#x884C;&#x51FD;&#x6570;&#x8F6C;&#x6362;&#x4E3A;Promise&#x5BF9;&#x8C61;&#xFF0C;&#x770B;&#x770B;&#x7528;Promise&#x5982;&#x4F55;&#x7B80;&#x5316;&#x5F02;&#x6B65;&#x5904;&#x7406;&#xFF1A;</p>
<pre><code class="lang-javascript"><span class="hljs-comment">// ajax&#x51FD;&#x6570;&#x5C06;&#x8FD4;&#x56DE;Promise&#x5BF9;&#x8C61;:</span>
<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">ajax</span>(<span class="hljs-params">method, url, data</span>) </span>{
    <span class="hljs-keyword">var</span> request = <span class="hljs-keyword">new</span> XMLHttpRequest();
    <span class="hljs-keyword">return</span> <span class="hljs-keyword">new</span> <span class="hljs-built_in">Promise</span>(<span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params">resolve, reject</span>) </span>{
        request.onreadystatechange = <span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params"></span>) </span>{
            <span class="hljs-keyword">if</span> (request.readyState === <span class="hljs-number">4</span>) {
                <span class="hljs-keyword">if</span> (request.status === <span class="hljs-number">200</span>) {
                    resolve(request.responseText);
                } <span class="hljs-keyword">else</span> {
                    reject(request.status);
                }
            }
        };
        request.open(method, url);
        request.send(data);
    });
}

<span class="hljs-keyword">var</span> p = ajax(<span class="hljs-string">&apos;GET&apos;</span>, <span class="hljs-string">&apos;/api/categories&apos;</span>);
p.then(<span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params">text</span>) </span>{ <span class="hljs-comment">// &#x5982;&#x679C;AJAX&#x6210;&#x529F;&#xFF0C;&#x83B7;&#x5F97;&#x54CD;&#x5E94;&#x5185;&#x5BB9;</span>

}).catch(<span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params">status</span>) </span>{ <span class="hljs-comment">// &#x5982;&#x679C;AJAX&#x5931;&#x8D25;&#xFF0C;&#x83B7;&#x5F97;&#x54CD;&#x5E94;&#x4EE3;&#x7801;</span>

});
</code></pre>
<p>&#x9664;&#x4E86;&#x4E32;&#x884C;&#x6267;&#x884C;&#x82E5;&#x5E72;&#x5F02;&#x6B65;&#x4EFB;&#x52A1;&#x5916;&#xFF0C;Promise&#x8FD8;&#x53EF;&#x4EE5;&#x5E76;&#x884C;&#x6267;&#x884C;&#x5F02;&#x6B65;&#x4EFB;&#x52A1;&#x3002;</p>
<p>&#x8BD5;&#x60F3;&#x4E00;&#x4E2A;&#x9875;&#x9762;&#x804A;&#x5929;&#x7CFB;&#x7EDF;&#xFF0C;&#x6211;&#x4EEC;&#x9700;&#x8981;&#x4ECE;&#x4E24;&#x4E2A;&#x4E0D;&#x540C;&#x7684;URL&#x5206;&#x522B;&#x83B7;&#x5F97;&#x7528;&#x6237;&#x7684;&#x4E2A;&#x4EBA;&#x4FE1;&#x606F;&#x548C;&#x597D;&#x53CB;&#x5217;&#x8868;&#xFF0C;&#x8FD9;&#x4E24;&#x4E2A;&#x4EFB;&#x52A1;&#x662F;&#x53EF;&#x4EE5;&#x5E76;&#x884C;&#x6267;&#x884C;&#x7684;&#xFF0C;&#x7528;<code>Promise.all()</code>&#x5B9E;&#x73B0;&#x5982;&#x4E0B;&#xFF1A;</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">var</span> p1 = <span class="hljs-keyword">new</span> <span class="hljs-built_in">Promise</span>(<span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params">resolve, reject</span>) </span>{
    setTimeout(resolve, <span class="hljs-number">500</span>, <span class="hljs-string">&apos;P1&apos;</span>);
});
<span class="hljs-keyword">var</span> p2 = <span class="hljs-keyword">new</span> <span class="hljs-built_in">Promise</span>(<span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params">resolve, reject</span>) </span>{
    setTimeout(resolve, <span class="hljs-number">600</span>, <span class="hljs-string">&apos;P2&apos;</span>);
});
<span class="hljs-comment">// &#x540C;&#x65F6;&#x6267;&#x884C;p1&#x548C;p2&#xFF0C;&#x5E76;&#x5728;&#x5B83;&#x4EEC;&#x90FD;&#x5B8C;&#x6210;&#x540E;&#x6267;&#x884C;then:</span>
<span class="hljs-built_in">Promise</span>.all([p1, p2]).then(<span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params">results</span>) </span>{
    <span class="hljs-built_in">console</span>.log(results); <span class="hljs-comment">// &#x83B7;&#x5F97;&#x4E00;&#x4E2A;Array: [&apos;P1&apos;, &apos;P2&apos;]</span>
});
</code></pre>
<p>&#x6709;&#x4E9B;&#x65F6;&#x5019;&#xFF0C;&#x591A;&#x4E2A;&#x5F02;&#x6B65;&#x4EFB;&#x52A1;&#x662F;&#x4E3A;&#x4E86;&#x5BB9;&#x9519;&#x3002;&#x6BD4;&#x5982;&#xFF0C;&#x540C;&#x65F6;&#x5411;&#x4E24;&#x4E2A;URL&#x8BFB;&#x53D6;&#x7528;&#x6237;&#x7684;&#x4E2A;&#x4EBA;&#x4FE1;&#x606F;&#xFF0C;&#x53EA;&#x9700;&#x8981;&#x83B7;&#x5F97;&#x5148;&#x8FD4;&#x56DE;&#x7684;&#x7ED3;&#x679C;&#x5373;&#x53EF;&#x3002;&#x8FD9;&#x79CD;&#x60C5;&#x51B5;&#x4E0B;&#xFF0C;&#x7528;<code>Promise.race()</code>&#x5B9E;&#x73B0;&#xFF1A;</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">var</span> p1 = <span class="hljs-keyword">new</span> <span class="hljs-built_in">Promise</span>(<span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params">resolve, reject</span>) </span>{
    setTimeout(resolve, <span class="hljs-number">500</span>, <span class="hljs-string">&apos;P1&apos;</span>);
});
<span class="hljs-keyword">var</span> p2 = <span class="hljs-keyword">new</span> <span class="hljs-built_in">Promise</span>(<span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params">resolve, reject</span>) </span>{
    setTimeout(resolve, <span class="hljs-number">600</span>, <span class="hljs-string">&apos;P2&apos;</span>);
});
<span class="hljs-built_in">Promise</span>.race([p1, p2]).then(<span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params">result</span>) </span>{
    <span class="hljs-built_in">console</span>.log(result); <span class="hljs-comment">// &apos;P1&apos;</span>
});
</code></pre>
<p>&#x7531;&#x4E8E;<code>p1</code>&#x6267;&#x884C;&#x8F83;&#x5FEB;&#xFF0C;Promise&#x7684;<code>then()</code>&#x5C06;&#x83B7;&#x5F97;&#x7ED3;&#x679C;<code>&apos;P1&apos;</code>&#x3002;<code>p2</code>&#x4ECD;&#x5728;&#x7EE7;&#x7EED;&#x6267;&#x884C;&#xFF0C;&#x4F46;&#x6267;&#x884C;&#x7ED3;&#x679C;&#x5C06;&#x88AB;&#x4E22;&#x5F03;&#x3002;</p>
<p>&#x5982;&#x679C;&#x6211;&#x4EEC;&#x7EC4;&#x5408;&#x4F7F;&#x7528;Promise&#xFF0C;&#x5C31;&#x53EF;&#x4EE5;&#x628A;&#x5F88;&#x591A;&#x5F02;&#x6B65;&#x4EFB;&#x52A1;&#x4EE5;&#x5E76;&#x884C;&#x548C;&#x4E32;&#x884C;&#x7684;&#x65B9;&#x5F0F;&#x7EC4;&#x5408;&#x8D77;&#x6765;&#x6267;&#x884C;&#x3002;</p>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="../基础/箭头函数.html" class="navigation navigation-prev " aria-label="Previous page: 箭头函数">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="../基础/generator.html" class="navigation navigation-next " aria-label="Next page: generator">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"Promise","level":"1.2.8.7","depth":3,"next":{"title":"generator","level":"1.2.8.8","depth":3,"path":"基础/generator.md","ref":"基础/generator.md","articles":[]},"previous":{"title":"箭头函数","level":"1.2.8.6","depth":3,"path":"基础/箭头函数.md","ref":"基础/箭头函数.md","articles":[]},"dir":"ltr"},"config":{"plugins":["lunr","pageview-count","chapter-fold","back-to-top-button","code","hide-element","-sharing","sharing-plus","custom-favicon"],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"chapter-fold":{},"search":{},"sharing-plus":{"qq":false,"all":["facebook","google","twitter","instapaper","linkedin","pocket","stumbleupon"],"douban":false,"facebook":true,"weibo":false,"instapaper":false,"whatsapp":false,"hatenaBookmark":false,"twitter":true,"messenger":false,"line":false,"vk":false,"pocket":true,"google":false,"viber":false,"stumbleupon":false,"qzone":false,"linkedin":false},"lunr":{"ignoreSpecialCharacters":false,"maxIndexSize":1000000},"code":{"copyButtons":true},"hide-element":{"elements":[".gitbook-link"]},"fontsettings":{"theme":"white","family":"sans","size":2},"highlight":{},"favicon":"js.ico","back-to-top-button":{},"pageview-count":{},"custom-favicon":{},"sharing":{"qq":true,"all":["douban","facebook","google","instapaper","linkedin","twitter","weibo","messenger","qq","qzone","viber","whatsapp"],"douban":true,"facebook":true,"weibo":true,"twitter":true,"pocket":true,"google":true,"qzone":true},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","author":"Veng","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"JavaScript学习","language":"zh-hans","gitbook":"*","description":"javaScript的学习笔记"},"file":{"path":"浏览器/Promise.md","mtime":"2020-12-10T02:10:04.990Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2020-12-10T03:00:51.663Z"},"basePath":"..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../gitbook/gitbook.js"></script>
    <script src="../gitbook/theme.js"></script>
    
        
        <script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-pageview-count/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-chapter-fold/chapter-fold.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-back-to-top-button/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-code/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-hide-element/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-sharing-plus/buttons.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

